package cn.com.mdx.sort.practice.collinearpoints;

/**
 * <p> 线段类
 *
 * @author ：huangy
 * @date ：Created in 2020/9/16 5:18 下午
 */
public class LineSegment {

    /**
     * 线段端点p
     */
    private final Point p;

    /**
     * 线段端点q
     */
    private final Point q;

    public LineSegment(Point p, Point q) {
        if (p == null || q == null) throw new NullPointerException("传入点为空");
        this.p = p;
        this.q = q;
    }

    /**
     * @return void
     * @Author huangy
     * @description //TODO 画线段
     * @date 3:45 下午 2020/9/17
     **/
    public void draw() {
        p.drawTo(q);
    }

    public String toString() {
        return "该线段的两个端点是：(" + p.getX() + "," + p.getY() + "),(" + q.getX() + "," + q.getY() + ")";
    }
}
